

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.io.*,java.sql.*,java.util.*" %>
<%@page import="java.lang.ClassNotFoundException" %>



<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
     
            
       
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/omapp";
        Connection conn = DriverManager.getConnection(url,"root", "");
         
        String pt_id = request.getParameter("ptid");
        String pt_name = request.getParameter("ptname");
        String pt_cat = request.getParameter("ptcat");
        String pt_comp = request.getParameter("ptcomp");
        String pr_id = request.getParameter("prid");
        float bprice = Float.parseFloat(request.getParameter("bprice"));
        float sprice = Float.parseFloat(request.getParameter("sprice"));
        String pdesc = request.getParameter("pdesc");
        
        String sql = "INSERT INTO `product_master`(`product_id`, `product_name`, `product_cat`, `product_comp`, `party_id`, `base_price`, `sell_price`, `product_desc`) VALUES (?,?,?,?,?,?,?,?) ";
        PreparedStatement pstmt = conn.prepareStatement(sql);
        pstmt.setString(1, pt_id);
        pstmt.setString(2, pt_name);
        pstmt.setString(3, pt_cat);
        pstmt.setString(4, pt_comp);
        pstmt.setString(5, pr_id);
        pstmt.setFloat(6, bprice);
        pstmt.setFloat(7, sprice);
        pstmt.setString(8, pdesc);
        
        
        int result = pstmt.executeUpdate();
        
        if(result==1)
                       {
            System.out.println("DATA INSERTED");
        }
        response.sendRedirect("product.jsp");
        %>
    </body>
</html>
